program Project2;

{$APPTYPE CONSOLE}

type
  pelement = ^element;
  element = record
  value : Integer;
  next : pelement;
  end;

uses
  SysUtils;

var
  fin : textfile;
  n, i, a: integer;
  head : pelement;

procedure PrintList (head : pelement);
var current : pelement;
begin
  current := head;
  while (current <> nil) do
  begin
    Writeln (current^.value);
    current := current^.next;
  end;
end;

function Delete (var head : pelement):integer;
var tmp : pelement;
begin
  if (head <> nil) then
  begin
    tmp := head^.next;
    DeleteFromBegin := head^.value;
    Dispose (head);
    head := tmp;
  end;
end;

procedure Add (var head : pelement; num : integer);
var tmp : pelement;
begin
  tmp := head;
  New (head);
  head^.value := num;
  head^.next := tmp;
end;

begin
  assignfile (fin, 'input.txt');
  Reset (fin);
  Readln(fin, n);

  for i := 0 to n-1 do
  begin
    read (fin, a);
    Add(head, a);
  end;

  PrintList(head);

  for i := 0 to n-1 do
    Delete(head);


  CloseFile (fin);
  Readln;
end.
